package org.duomn.xmltool.model;

import java.math.BigDecimal;
import java.math.RoundingMode;

import org.duomn.xmltool.transfer.Transfer;

public class SizeM2GUnitTranfer implements Transfer {
	
	@Override
	public String format(Object obj) {
		BigDecimal big = null;
		if (obj instanceof Long) {
			long size = (Long) obj;
			big = new BigDecimal(size);
		} else if (obj instanceof Float) {
			float size = (Float) obj;
			big= new BigDecimal(size);
		} else if (obj instanceof Double) {
			double size = (Double) obj;
			big = new BigDecimal(size);
		} else if (obj instanceof Integer) {
			int size = (Integer) obj;
			big = new BigDecimal(size);
		}
		BigDecimal gNum = big.divide(new BigDecimal(1024)).setScale(0, RoundingMode.HALF_UP);
		return gNum.toString() + "G";
	}

}
